﻿using HPIT.MemberPoint.Business;
using HPIT.MemberPoint.Common;
using HPIT.MemberPoint.Entity.ViewModel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace Huang.Project.Mvc.Controllers
{
    public class MemberCardController : Controller
    {
        // GET: MemberCard
      
            private CardLevelService _CardLevelService = new CardLevelService();
            private MemberCardService _MemberCardService = new MemberCardService();

            /// <summary>
            /// 加载会员列表
            /// </summary>
            /// <returns></returns>
            public ActionResult Index()
            {
                //1.获取会员等级信息
                var cardLevels = _CardLevelService.GetList(e => true).Select(e => new SelectListItem() { Text = e.CL_LevelName, Value = e.CL_ID.ToString() }).ToList();
                cardLevels.Insert(0, new SelectListItem() { Text = "全部", Value = "0" });
                ViewBag.CardLevel = cardLevels;

                //2.获取状态信息

                var cardTypeList = EnumHelper.EnumListDic<CardStateTypeEnum>("全部", "0");
                var cardTypeSelectList = new SelectList(cardTypeList, "value", "key");
                ViewBag.CardTypeSelectList = cardTypeSelectList;

                return View();
            }

            public ActionResult GetPagedMemberCardList(GetPagedMemberCardListViewModel viewModel)
            {
                var result = _MemberCardService.GetPagedMemberCardList(viewModel);
                return Json(result.Data);
            }

          
            

           

            /// <summary>
            /// 删除会员
            /// </summary>
            /// <param name="id"></param>
            /// <returns></returns>
            public ActionResult Delete(int id)
            {
                var result = _MemberCardService.DeleteMemberCard(id);
                return Json(result);
            }

            //public ActionResult Transfer()
            //{

            //    var viewModel = new TransferMoneyViewModel()
            //    {
            //        FromMemberCardId = "1234516",
            //        Remark = "转你两个亿，拿去浪~~~",
            //        ToMemberCardId = "654321",
            //        TransferMoney = 2,
            //        UserId = 1
            //    };
            //    var result = _MemberCardService.TransferMoney(viewModel);
            //    return Content("结束");

            //}
       
        }
}